package com.example;


import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
import de.greenrobot.daogenerator.Schema;

public class CreateGreendao {

    public static void main(String[] args) {
        Schema schema = new Schema(1, "com.lanou.dllo.soccernews.bean.greendao");


        addRecommendEntity(schema);
        addArticlesEntity(schema);
        addCollectionBeanArticlesEntity(schema);
        addDeepBeanArticlesEntity(schema);
        addUser(schema);
        try {
            new DaoGenerator().generateAll(schema, "./app/src/main/java/");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /*
    *  private int id;
        private String title;
        private String share_title;
        private String description;
        private int comments_total;
        private String share;
        private String thumb;
        private String published_at;
        private boolean top;
        private String url;
        private String channel;
        private String scheme;*/
    private static void addRecommendEntity(Schema schema) {
        Entity entity = schema.addEntity("RecommendEntity");
//        entity.addLongProperty("_id").primaryKey().autoincrement();
        entity.addLongProperty("id").primaryKey();
        entity.addStringProperty("title");
        entity.addStringProperty("share_title");
        entity.addStringProperty("description");
        entity.addStringProperty("share");
        entity.addStringProperty("thumb");
        entity.addStringProperty("published_at");
        entity.addStringProperty("url");
        entity.addStringProperty("channel");
        entity.addStringProperty("scheme");
        entity.addBooleanProperty("top");
        entity.addLongProperty("comments_total");


    }

    private static void addArticlesEntity(Schema schema) {

        Entity entity = schema.addEntity("ArticlesEntity");

        entity.addLongProperty("id").primaryKey();
        entity.addStringProperty("title");
        entity.addStringProperty("share_title");
        entity.addStringProperty("description");
        entity.addStringProperty("share");
        entity.addStringProperty("thumb");
        entity.addStringProperty("published_at");
        entity.addStringProperty("url");
        entity.addStringProperty("channel");
        entity.addStringProperty("scheme");
        entity.addBooleanProperty("top");
        entity.addLongProperty("comments_total");
        entity.addStringProperty("label");
        entity.addStringProperty("label_color");


    }


    private static void addCollectionBeanArticlesEntity(Schema schema) {


        Entity entity = schema.addEntity("CollectionBeanArticlesEntity");


        entity.addLongProperty("id").primaryKey();
        entity.addStringProperty("title");
        entity.addStringProperty("share_title");
        entity.addLongProperty("comments_total");
        entity.addStringProperty("share");
        entity.addStringProperty("thumb");
        entity.addStringProperty("published_at");
        entity.addStringProperty("url");
        entity.addStringProperty("channel");
        entity.addStringProperty("scheme");
        entity.addBooleanProperty("top");

    }

    private static void addDeepBeanArticlesEntity(Schema schema) {
    /*
    * private int id;
        private String title;
        private String share_title;
        private String description;
        private int comments_total;
        private String share;
        private String thumb;
        private String published_at;
        private boolean top;
        private String url;
        private String channel;
        private String scheme;*/

        Entity entity = schema.addEntity("DeepBeanArticlesEntity");


        entity.addLongProperty("id").primaryKey();
        entity.addStringProperty("title");
        entity.addStringProperty("share_title");
        entity.addLongProperty("comments_total");
        entity.addStringProperty("share");
        entity.addStringProperty("thumb");
        entity.addStringProperty("published_at");
        entity.addStringProperty("url");
        entity.addStringProperty("channel");
        entity.addStringProperty("scheme");
        entity.addBooleanProperty("top");
    }


    private static void addCircleArticlesEntity(Schema schema) {
    /*
    *  private int id;
    private String title;
    private String share_title;
    private String description;
    private int comments_total;
    private String share;
    private String thumb;
    private String published_at;
    private boolean top;
    private String url;
    private String channel;
    private String scheme;
    private TopicEntity topic;*/

        Entity circle = schema.addEntity("Circle");

        circle.addIdProperty().primaryKey();
        circle.addStringProperty("title");
        circle.addStringProperty("share_title");
        circle.addLongProperty("comments_total");
        circle.addStringProperty("share");
        circle.addStringProperty("description");
        circle.addStringProperty("thumb");
        circle.addStringProperty("published_at");
        circle.addStringProperty("url");
        circle.addStringProperty("channel");
        circle.addStringProperty("scheme");
        circle.addBooleanProperty("top");


        Entity top = schema.addEntity("Top");
        top.addIdProperty().primaryKey();
        top.addStringProperty("thumb");
        top.addStringProperty("content");

        Property idCircle = circle.addLongProperty("id").getProperty();
        circle.addToOne(top, idCircle);


    }


    private static void addUser(Schema schema) {
        // TODO Auto-generated method stub
        Entity entity = schema.addEntity("Users");

      //  entity.addStringProperty("name").unique();
        entity.addStringProperty("username").unique();
        entity.addStringProperty("password");
        entity.addStringProperty("tel").primaryKey();
        entity.addBooleanProperty("sex");
        entity.addStringProperty("address");
        entity.addStringProperty("collect");
    }
}
